import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { LiushuiVO, LiushuiForm, LiushuiQuery } from '@/api/liushui/liushui/types';
import { id } from 'element-plus/es/locale/index.mjs';

/**
 * 查询银行流水列表
 * @param query
 * @returns {*}
 */

export const listLiushui = (query?: LiushuiQuery): AxiosPromise<LiushuiVO[]> => {
  return request({
    url: '/liushui/liushui/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询银行流水详细
 * @param id
 */
export const getLiushui = (id: string | number): AxiosPromise<LiushuiVO> => {
  return request({
    url: '/liushui/liushui/' + id,
    method: 'get'
  });
};

/**
 * 新增银行流水
 * @param data
 */
export const addLiushui = (data: LiushuiForm) => {
  return request({
    url: '/liushui/liushui',
    method: 'post',
    data: data
  });
};

/**
 * 修改银行流水
 * @param data
 */
export const updateLiushui = (data: LiushuiForm) => {
  return request({
    url: '/liushui/liushui',
    method: 'put',
    data: data
  });
};

/**
 * 删除银行流水
 * @param id
 */
export const delLiushui = (id: string | number | Array<string | number>) => {
  return request({
    url: '/liushui/liushui/' + id,
    method: 'delete'
  });
};

/**
 * 根据ID列表导出银行流水
 * @param ids 需要导出的银行流水记录的主键ID列表
 */
export const exportSelectedLiushui = (ids: Array<string | number>): AxiosPromise<Blob> => {
  return request({
    url: '/liushui/liushui/exportSelected',
    method: 'post',
    data: ids,
    headers: {
      'Content-Type': 'application/json'
    },
    responseType: 'blob' // 确保响应类型为blob，以便处理文件下载
  });
};


/**
 * 清空表数据
 * 
 */
export const clearLiushui = () => {
  return request({
    url: '/liushui/liushui/clear',
    method: 'delete'
  });
};